//    Copyright (C) Kherty.  All rights reserved.
using System;
using System.Collections.Generic;
using System.Reflection;
using System.Text;
using System.Windows.Media.Media3D;

namespace OpenLS.Chart.UI
{
    static class CameraHelper
    {
        public static Matrix3D GetViewMatrix(Camera camera)
        {
            if (camera is MatrixCamera)
                return ((MatrixCamera)camera).ViewMatrix;
            return (Matrix3D)GetViewMatrixInfo.Invoke(camera, new object[0]);

        }
        public static Matrix3D GetProjectionMatrix(Camera camera, double aspectRatio)
        {
            if (camera is MatrixCamera)
                return ((MatrixCamera)camera).ProjectionMatrix;
            return (Matrix3D)GetProjectionMatrixInfo.Invoke(camera, new object[]{aspectRatio});

        }
        private static readonly MethodInfo GetProjectionMatrixInfo =
typeof(Camera).GetMethod("GetProjectionMatrix", BindingFlags.Instance | BindingFlags.NonPublic);

        private static readonly MethodInfo GetViewMatrixInfo =
            typeof(Camera).GetMethod("GetViewMatrix", BindingFlags.Instance | BindingFlags.NonPublic);

    }
}
